#ifndef LOGINDIALOG_H
#define LOGINDIALOG_H

#include <QDialog>
#include"global.h"
#include"httpmgr.h"
#include"errorqueuemgr.h"
namespace Ui {
class LoginDialog;
}

class LoginDialog : public QDialog
{
    Q_OBJECT

public:
    explicit LoginDialog(QWidget *parent = nullptr);
    void setupconnection();
    ~LoginDialog();
signals:
    void SwitchToReg();
    void SwitchToResetpsw();
public slots:
    void slot_login_http_finish(ReqId id,QString res,Ecode error);
private slots:
    void on_login_btn_clicked();
    void onUsertextChange();
    void onPswtextChange();



private:
    bool Validate(QString fieldname,QString text);
    void InitHttpHandler();
private:
    Ui::LoginDialog *ui;
    ErrorQueueManager m_errorqueue;
    std::unordered_map<ReqId,std::function<void(QJsonObject&)>>m_handlers;
};

#endif // LOGINDIALOG_H
